/*
 *  System.cpp
 *  SpaceTrader
 *
 *  Created by Andrew on 10/16/12.
 *  Copyright 2012 The Hex Pistols. All rights reserved.
 *
 */

#include "System.h"
System::System() : name(""), x(0), y(0), icon(NULL), planets(NULL)  {
    
}

System::System(std::string newName, int newX, int newY, std::vector<Planet*> newPlanets, SDL_Surface *newIcon) : name(newName),
                    x(newX), y(newY), icon(newIcon), planets(newPlanets)
{
	name = newName;
	x = newX;
	y = newY;
	planets = newPlanets;
	icon = newIcon;
}

System::System(const System &S) : name(S.name), x(S.x), y(S.y), icon(S.icon), planets(std::vector<Planet*>(S.planets.size())) {
    for (unsigned int i = 0; i < S.planets.size(); i++){
        planets[i] = S.planets[i];
    }
}

System::~System() 
{
}
System& System::operator=(System &S){
    if (&S != this){
        delete icon;
        for (unsigned int i = 0; i < planets.size(); i++){
            delete planets[i];
        }
        planets = std::vector<Planet*>(S.planets.size());
        for (unsigned int i = 0; i < planets.size(); i++){
            planets[i] = S.planets[i];
        }
        name = S.name;
        x = S.x;
        y = S.y;
        icon = S.icon;
    }
    return *this;
}

std::string System::getName() 
{
	return name;
}

int System::getX() 
{
	return x;
}

int System::getY() 
{
	return y;
}

std::vector<Planet*> System::getPlanets() 
{
	return planets;
}

void System::show(SDL_Surface *screen) 
{
	apply_surface(x, y, icon, screen);
}